import { BaseSkill } from '../BaseSkill';
import { DamageType, SkillType } from '../../types';
import { General } from '../../models/General';
import { Battle } from '../../models/Battle';

export class YuanDaYuanAi extends BaseSkill {
  private readonly SELF_DAMAGE_RATIO = 0.2;  // 20% 智力的谋伤
  private readonly DAMAGE_BOOST_RATIO = 0.5; // 50% 伤害提升

  constructor() {
    super(
      'yuanDaYuanAi',
      '愿打愿挨',
      SkillType.Active,
      DamageType.Strategy,
      0.5,        // 50% 触发概率
      3,          // 3回合CD
      2           // 2回合持续
    );
  }

  execute(source: General, battle: Battle): void {
    if (!this.canUse() || Math.random() > this.probability) return;

    // 对自身造成谋略伤害
    const selfDamage = source.attributes.intelligence * this.SELF_DAMAGE_RATIO;
    source.receiveDamage(selfDamage);
    
    // 添加伤害提升效果
    source.addEffect({
      type: 'strategyDamageBoost',
      value: this.DAMAGE_BOOST_RATIO,
      duration: this.duration,
      stackable: false,
      source: this.id,
      timestamp: Date.now()
    });

    source.addEffect({
      type: 'physicalDamageBoost',
      value: this.DAMAGE_BOOST_RATIO,
      duration: this.duration,
      stackable: false,
      source: this.id,
      timestamp: Date.now()
    });

    this.startCooldown();
  }
}
